<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的第一个程序 - 计数器</title>
</head>
<body>
    <h1>计数器</h1>
    <p id="count">0</p >
    <button id="increment">增加</button>
    <button id="decrement">减少</button>

    <script>
        let count = 0;
        const countElement = document.getElementById('count');
        const incrementButton = document.getElementById('increment');
        const decrementButton = document.getElementById('decrement');

        incrementButton.addEventListener('click', () => {
            count++;
            countElement.textContent = count;
        });

        decrementButton.addEventListener('click', () => {
            count--;
            countElement.textContent = count;
        });
    </script>
</body>
</html>